package co.ntt.spms.conf;

import java.util.Locale;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanFactoryUtil {
	private static ApplicationContext ctx = new ClassPathXmlApplicationContext(
			"com/idstrust/wiseone/localbox/conf/applicationContext.xml");

	private static Locale locale = Locale.getDefault();

	public static void setLocale(Locale locale) {
		BeanFactoryUtil.locale = locale;
	}

	/**
	 * Spring 빈을 가지고 옵니다.
	 * 
	 * @param name
	 * @return
	 */
	public static Object getBean(String name) {
		return ctx.getBean(name);
	}

	/**
	 * 메세지를 가지고 옵니다.
	 * 
	 * @param code
	 * @return
	 */
	public static String getMessage(String code) {
		return ctx.getMessage(code, null, locale);
	}

	/**
	 * 메세지를 가지고 옵니다.
	 * 
	 * @param code
	 * @param args
	 * @return
	 */
	public static String getMessage(String code, Object[] args) {
		return ctx.getMessage(code, args, locale);
	}
}
